﻿using NCS.IConnect.Core.Utilities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NCS.IConnect.Core.WebApi.Description
{
    /// <summary>
    /// This <see cref="Attribute"/> which is annotated on action methods to provider HTTP header description.
    /// </summary>
    public abstract class HeaderAttribute: Attribute
    {
        /// <summary>
        /// Gets the name of the HTTP header.
        /// </summary>
        /// <value>The name of the HTTP header.</value>
        public string HeaderName { get; private set; }

        /// <summary>
        /// Gets the description of the HTTP header.
        /// </summary>
        /// <value>The description of the HTTP header.</value>
        public string Description { get; private set; }

        /// <summary>
        /// Gets or sets the remark information for the HTTP header.
        /// </summary>
        /// <value>The remark information for the HTTP header.</value>
        public string Remark { get; set; }

        /// <summary>
        /// Initializes a new instance of the <see cref="HeaderAttribute"/> class.
        /// </summary>
        /// <param name="headerName">Name of the header.</param>
        /// <param name="description">The description.</param>
        /// <param name="remark">The remark.</param>
        public HeaderAttribute(string headerName, string description, string remark = null)
        {
            Guard.ArgumentNotNullOrEmpty(headerName, "headerName");
            Guard.ArgumentNotNullOrEmpty(description, "description");

            this.HeaderName = headerName;
            this.Description = description;
            this.Remark = remark;
        }
        /// <summary>
        /// Creates the <see cref="HttpHeaderDescriptor"/>.
        /// </summary>
        /// <returns>The <see cref="HttpHeaderDescriptor"/>.</returns>
        public HttpHeaderDescriptor CreateHeaderDescriptor()
        {
            return new HttpHeaderDescriptor(this.HeaderName, this.Description, this.Remark);
        }
    }
}